package cn.sdormitory.component.bindValue.query.mapping;


import cn.hutool.core.convert.Convert;
import cn.sdormitory.basedata.service.BClassService;
import cn.sdormitory.common.IdAndName;
import cn.sdormitory.common.utils.ContainerUtil;
import cn.sdormitory.component.bindValue.bean.info.BindInfo;
import cn.sdormitory.sys.service.SysDictDetailService;
import com.google.common.collect.Table;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component("classMappingQuery")
public class ClassMappingQuery implements MappingQuery{

    @Resource
    private BClassService classService;

    @Override
    public Map<String, String> getMapping(BindInfo bindInfo, List<String> variables, Table<String, String, String> params) {
        List<IdAndName<Long>> idAndNames = classService.getIdAndNames();
        return ContainerUtil.toMapSafe(idAndNames,item-> Convert.toStr(item.getId()), IdAndName::getName);
    }
}
